home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / edebug / permute-index < prev    next >
Encoding:
Text File  |  1994-09-20  |  2.5 KB  |  105 lines

  1. #!/bin/csh -f
  2. # Generate a permuted index of all names.
  3. # The result is a file called $MANUAL.$SUFFIX
  4.  
  5. # You will need to modify this for your needs.
  6.  
  7.  
  8. set TEXINDEX=texindex  # path to texindex command
  9. #set EMACS=gnuemacs     # your emacs command
  10. #set TEX=tex             # your tex command
  11.  
  12. set SUFFIX=cp
  13. set MANUAL=edebug  # the base name of the manual
  14.  
  15. # goto 3
  16.  
  17. 1:
  18. echo "Extract raw index from texinfo ${SUFFIX} index."
  19. # Let texindex combine duplicate entries, later.
  20. # But it wants to protect non-alphanumerics thus confusing ptx.
  21. # Also change `\ ' to just a ` ', since texindex will fail. This is produced 
  22. # by `@findex two words' in an example environment (no doubt among others).
  23. # delete wrapper parens
  24. # change dots {} to dots{}
  25. # change {-} to char form, so ptx wont ignore it.
  26. # delete leading \entry {
  27. # change '\ ' to ' '
  28. # change lines with = < > since they mess up field extraction.
  29. # separate into fields delimited by "
  30. cat ${MANUAL}.${SUFFIX} | \
  31.     sed \
  32.     -e 's/(\([^)]*\))/\1/' \
  33.     -e 's/\\dots {}/(\\dots{})/' \
  34.     -e "s/{-}/{{\\tt\\char'055}}/" \
  35.     -e 's,^[^ ]* {,,' \
  36.     -e 's, },},' \
  37.     -e 's,\\ , ,g' \
  38.     -e 's/{\\tt\\char61}/=/' \
  39.     -e 's/{\\tt\\gtr}/>/' \
  40.     -e 's/{\\tt\\less}/</' \
  41.     -e 's/}{/"/g' \
  42.     | awk -F\" '{print $2, $1}' >! permuted.raw
  43.  
  44. 2:
  45. # Build break file for ptx.
  46. cat <<EOF > permuted.break
  47. -
  48. :
  49. EOF
  50. # Build the ignore file for ptx.
  51. # We would like to ignore "and", "or", and "for", 
  52. # but ptx ignores ignore words even if they stand alone.
  53. cat <<EOF > permuted.ignore
  54. the
  55. in
  56. to
  57. as
  58. a
  59. an
  60. at
  61. of
  62. on
  63. them
  64. how
  65. from
  66. by
  67. EOF
  68.  
  69. echo "Make troff permuted index."
  70. ptx -i permuted.ignore -b permuted.break -f -r -w 144 \
  71.      < permuted.raw >! permuted.t
  72.  
  73. 3:
  74. echo "Extract the desired fields."
  75. awk -F\" '{printf "%s\"%s\"%s\n", $4,$6,$9}' permuted.t >! permuted.fields 
  76.  
  77. 4:
  78. echo "Format for texindex."
  79. # delete lines that start with "and ", "for "
  80. sed     < permuted.fields \
  81.     -e 's/=/{\\tt\\char61}/' \
  82.     -e 's/>/{\\tt\\gtr}/' \
  83.     -e 's/</{\\tt\\less}/' \
  84.     -e '/"and /d' \
  85.     -e '/"for /d' \
  86.   | awk -F\" 'NF>0 {if ($1=="") {\
  87.       print "\entry {" $2 "}{" 0+$3 "}{" $2 "}" }\
  88.     else {\
  89.       print "\entry {" $2 ", " $1 "}{" 0+$3 "}{" $2 ", " $1 "}"} }'\
  90.           > permuted.${SUFFIX}
  91.  
  92. 5:
  93. echo "Sort with texindex."
  94. ${TEXINDEX} permuted.${SUFFIX}
  95. #mv permuted.${SUFFIX}s ${MANUAL}.${SUFFIX}s
  96.  
  97. # The resulting permuted.${SUFFIX}s will be read when we run TeX 
  98. # on the manual the second time.  Or you can use permuted.texinfo here.
  99. #${TEX} permuted.texinfo
  100.  
  101. 6:
  102. echo "Clean up."
  103. rm -f permuted.fields permuted.t permuted.raw
  104. rm -f permuted.break permuted.ignore permuted.${SUFFIX}
  105.